package com.jinbiao.quasar.service;

import com.jinbiao.quasar.model.SysJob;
import com.jinbiao.quasar.model.SysJobLog;
import org.noear.solon.annotation.ProxyComponent;
import org.noear.solon.extend.sqltoy.annotation.Db;
import org.sagacity.sqltoy.dao.SqlToyLazyDao;
import org.sagacity.sqltoy.model.EntityQuery;

import java.util.List;

@ProxyComponent
public class JobService {
    @Db
    SqlToyLazyDao dao;
    public List<SysJob> findJobs(String name){
        List<SysJob> jobList = dao.findEntity(SysJob.class, EntityQuery.create().where("job_inner_name=?").values(name));
        return jobList;
    }

    public void addJobLog(SysJobLog log){
        dao.save(log);
    }

    public List<SysJobLog> findJobLogs(String name){
        List<SysJobLog> jobLogList = dao.findEntity(SysJobLog.class, EntityQuery.create().where("job_inner_name=?").values(name));
        return jobLogList;
    }
}
